package A1_二叉树;

public class LC_404左叶子之和 {
    public static class TreeNode{
        int val;
        TreeNode left;
        TreeNode right;
        TreeNode(){}
        TreeNode(int val){
            this.val=val;
        }
        TreeNode(int val, TreeNode left, TreeNode right){
            this.val=val;
            this.left=left;
            this.right=right;
        }
    }
    public int sumOfLeftLeaves(TreeNode root) {
        if(root==null)
            return 0;
        if(root.left==null && root.right==null)
            return 0;
        int leftnum=sumOfLeftLeaves(root.left);
        if(root.left!=null && root.left.left==null && root.left.right==null)
            leftnum=root.left.val;
        int rightnum=sumOfLeftLeaves(root.right);
//        if(root.right.left!=null && root.right.left.left==null && root.right.left.right==null)
//            rightnum=root.right.left.val;
        return leftnum+rightnum;
    }
}
